package com.zut.yyzx.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zut.yyzx.dto.BedDetailsDTO;
import com.zut.yyzx.dto.ExchangeDTO;
import com.zut.yyzx.pojo.Beddetails;
import com.zut.yyzx.service.BeddetailsService;
import com.zut.yyzx.utils.ResultVo;
import com.zut.yyzx.vo.BedDetailsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/beddetails")
//"床位详情管理"
@CrossOrigin
public class BeddetailsController {
    @Autowired
    private BeddetailsService beddetailsService;

    @GetMapping("/listBedDetailsVoPage")
    //"床位详细列表动态查询（分页）"
    public ResultVo<Page<BedDetailsVo>> listBedDetailsVoPage(BedDetailsDTO bedDetailsDTO) throws Exception{
        return beddetailsService.listBedDetailsVoPage(bedDetailsDTO);
    }
    @PostMapping("/updateBedDetails")
    //"更新床位使用详情-只能修改床位使用结束时间"
    public  ResultVo updateBedDetails(Beddetails beddetails) throws  Exception{
        beddetailsService.updateById(beddetails);
        return ResultVo.ok("编辑成功");
    }
    @PostMapping("/exchangeBed")
    //"床位调换"
    public ResultVo exchangeBed(ExchangeDTO exchangeDTO) throws Exception{
        return beddetailsService.exchangeBed(exchangeDTO);
    }
    @GetMapping("/delBedDetails")
    //"删除记录"
    public ResultVo delBedDetails(Integer id) throws Exception{
        beddetailsService.removeById(id);
        return ResultVo.ok("删除成功");
    }

}
